#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n, m, L, V;
struct node {
    ll d, v, x;
} a[100005];
int b[100005];
void solve1() {
    int cnt = 0;
    for (int i = 1; i <= n; i++) {
        if (a[i].v > V && a[i].d <= b[n]) cnt++;
    }
    printf("%d %lld\n", cnt, (n - 1));
}
void solve2() {
    int cnt = 0;
    for (int i = 1; i <= n; i++) {
        if (a[i].d <= b[n] && 2 * a[i].x * (b[n] - a[i].d) + a[i].v * a[i].v > V * V) cnt++;
    }
    printf("%d %lld\n", cnt, (n - 1));
}
int ex[25];
bool f[25][25];
int ans = 0;
void DFS(int x, int c, int flag) {
    bool fl = 1;
    if (flag) {
        for (int i = 1; i <= n; i++) {
            if (ex[i] != 0) {
                if (f[i][x] == 1) {
                    ex[i]--;
                    if (ex[i] == 0) fl = 0;
                } 
            }
        }
    }
    // cout << x << "-";
    // for (int i = 1; i <= n; i++) {
    //     cout << ex[i] << " ";
    // }
    // cout << endl;
    if (x == m && fl != 0) {
        fl = 0;
        // if (ans < c) {
        //     cout << c << ":" << endl;
        //     for (int i = 1; i <= n; i++) {
        //         cout << ex[i] << " ";
        //     }
        //     cout << endl;
        // }
        ans = max(ans, c);
    }
    
    if (fl == 1) {
        DFS(x + 1, c, 0);
        DFS(x + 1, c + 1, 1);
    }

    if (flag) {
        for (int i = 1; i <= n; i++) {
            if (f[i][x] == 1) {
                ex[i]++;
            } 
        }
    }
    
}
void solve3() {
    int cnt = 0;
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= m; j++) {
            if (a[i].d <= b[j] && 2 * a[i].x * (b[j] - a[i].d) + a[i].v * a[i].v > V * V) {
                if (!ex[i]) cnt++;
                ex[i]++;
                f[i][j] = 1;
            }
        }
    }
    // for (int i = 1; i <= n; i++) {
    //     cout << ex[i] << " -";
    // }
    // cout << endl;
    DFS(0, 0, 0);
    printf("%d %d\n", cnt, ans);
}
int main() {
    freopen("detect.in", "r", stdin);
    freopen("detect.out", "w", stdout);
    int T;
    scanf("%d", &T);
    while (T--) {
        scanf("%lld %lld %lld %lld", &n, &m, &L, &V);
        ans = 0;
        memset(a, 0, sizeof(a));
        memset(b, 0, sizeof(b));
        memset(ex, 0, sizeof(ex));
        memset(f, 0, sizeof(f));
        bool f1 = 1, f2 = 1, f3 = 1; // < = >
        for (int i = 1; i <= n; i++) {
            scanf("%lld %lld %lld", &a[i].d, &a[i].v, &a[i].x);
            if (a[i].x < 0) f2 = f3 = 0;
            if (a[i].x == 0) f1 = f3 = 0;
            if (a[i].x > 0) f1 = f2 = 0;
        }
        for (int i = 1; i <= m; i++) cin >> b[i];
        sort(b + 1, b + n + 1);
        if (f2 == 1) {
            solve1();
        } else if (f3 == 1) {
            solve2();
        } else {
            solve3();
        }
    }
    
    return 0;
}